import {reqcatelist} from "../../http/api"
let state={
    // 1.初始化数据
    list:[]
}
let getters={
    // 2.导出list 
    list(state){
        return state.list
    }
}

let mutations={
    // 3.修改list 
    changeList(state,list){
        state.list=list;
    }
}

let actions={
    // 4.list逻辑
    reqList({commit}){
        //发请求
        reqcatelist({istree:true}).then(res=>{
            if(res.data.code==200){
                //得到数据。给list赋值
               commit("changeList",res.data.list?res.data.list:[])
                
            }
        })
    }
}

export default {
    state,
    getters,
    mutations,
    actions,
    //命名空间
    namespaced:true
}